﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
using Microsoft.Phone.Controls;
using VirtualDreams.Turnstile;


namespace OttawaTourMap
{
    public partial class TourStartPage : PhoneApplicationPage
    {
        private bool isListLoadedFirst = true;
        // Constructor
        public TourStartPage()
        {
            InitializeComponent();
            //    DrawTourInfo();
            //  getData();
            TourInfoList.DataContext = App.TourList; //App.ViewModel;
           // this.Loaded += new RoutedEventHandler(MainPage_Loaded);// Load tours data for the ViewModel Items

        }

      

        private void getData()
        {
           // TourCalculator tourcalc = new TourCalculator();
           // tourcalc.getData();
        }

        private void DrawTourInfo()
        {
            //Image newImage = new Image();
            //Height="194" Margin="151,0,46,0" Source="Resources/Images/Image4.png" Stretch="Fill" MouseLeftButtonDown="Image_MouseLeftButtonDown"
           // newImage.Height = 194;


        }
        private void Image_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
        {


        }

        private void Image_ImageFailed(object sender, ExceptionRoutedEventArgs e)
        {

        }

        private void TourInfo_Loaded(object sender, RoutedEventArgs e)
        {

            // TourInfoList.AnimateTiles(VirtualDreams.Turnstile.EnterMode.Enter, VirtualDreams.Turnstile.YDirection.TopToBottom, VirtualDreams.Turnstile.ZDirection.FrontToBack);
        }

        private void ListBox_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {

        }

        private void TourInfo_Loaded_1(object sender, RoutedEventArgs e)
        {

        }

        private void TourInfoList_Loaded(object sender, RoutedEventArgs e)
        {

            // TourInfoTiles.AnimateTiles(VirtualDreams.Turnstile.EnterMode.Exit, VirtualDreams.Turnstile.YDirection.TopToBottom, VirtualDreams.Turnstile.ZDirection.FrontToBack);
        }

        private void TourInfoList_Loaded_1(object sender, RoutedEventArgs e)
        {
            
            TourInfoList.Opacity = 1;
            TourInfoList.AnimateTiles(VirtualDreams.Turnstile.EnterMode.Enter, VirtualDreams.Turnstile.YDirection.TopToBottom, VirtualDreams.Turnstile.ZDirection.FrontToBack);
            
            isListLoadedFirst = false;

        }

        private void Image_MouseLeftButtonDown_1(object sender, MouseButtonEventArgs e)
        {
            TourInfoList.AnimateTiles(VirtualDreams.Turnstile.EnterMode.Exit, VirtualDreams.Turnstile.YDirection.TopToBottom, VirtualDreams.Turnstile.ZDirection.FrontToBack);
            string message = "45.424585$-75.68608@45.419585$-75.678678@45.419525$-75.677369@45.423305$-75.683849@45.422627$-75.684814";
            NavigationService.Navigate(new Uri("/MainPage.xaml?tourCoordinates=" + message, UriKind.Relative));


        }

        private void TourInfoList_Loaded_2(object sender, RoutedEventArgs e)
        {
            if (isListLoadedFirst)
                TourInfoList.Opacity = 0;
            else
            {
                isListLoadedFirst = true;
            }
           
            // TourInfoList.Visibility = System.Windows.Visibility.Visible;
        }

        /*
         * /*
         * web client
         *  client.DownloadStringCompleted += client_DownloadStringCompleted;
   
         * client.DownloadStringAsync(new Uri("http://www.mybogussite.com/givemesomexml", UriKind.Absolute));

 


         * and

 

  
         * void client_DownloadStringCompleted(object sender, DownloadStringCompletedEventArgs e)
  
         * {
   
         * if (e.Error == null)
   
         * {
    
string xml = e.Result;
   } 
  }
         
         */
    }
}